//index.js
const HTTP = require('../../models/HTTP');
Page({
  data:{
    movies:[],
    total:"",
    idEnd:false
  },
  onLoad(){
    HTTP.getTop250({start:0}).then(res=>{
      var {subjects,total}=res.data;
      this.setData({
        movies:subjects,
        total
      })
    })
  },
  onReachBottom(){
    var length=this.data.movies.length;
    if(length<this.data.total){
      HTTP.getTop250({start:length}).then(res=>{
        var {subjects}=res.data;
        this.setData({
          movies:[...this.data.movies,...subjects]
        })
      })
    }else{
      console.log("已经到达底部")
      this.setData({
        idEnd:true
      })
    }
  }
})
